package com.example.mapper;

import com.example.entity.User;
import org.apache.ibatis.jdbc.SQL;

public class UserSqlProvider {
    public String getUsersByCondition(User user) {
        return new SQL() {{
            SELECT("*");
            FROM("users");
            if (user.getUsername() != null && !user.getUsername().isEmpty()) {
                WHERE("username = #{user.username}");
            }
            if (user.getAge() != null) {
                WHERE("age = #{user.age}");
            }
        }}.toString();
    }
}